import flet 
def controls():
    c = flet.Container(
        width=150,
        height=150,
        bgcolor="blue",
        border_radius=10,
        animate_opacity=300,
    )
    def animate_opacity(e):
        c.opacity = 0 if c.opacity == 1 else 1
        c.update()
    return  [flet.AppBar(title=flet.Text("Animate opacity"), bgcolor=flet.colors.SURFACE_VARIANT),c,
        flet.ElevatedButton(
     "click",
                on_click=animate_opacity,
     )]
def mainView():
    return flet.View(
                    "Animate opacity",
                    controls()
                )
def main(page: flet.Page):
    for c in controls():
        page.add(c)
if __name__=="__main__":
    flet.app(target=main)